// SDVector.cpp

#include "SDVector.h"

SDVector::SDVector()
: m_data(0), m_row(0), m_col(0)
{
}

SDVector::~SDVector()
{
	myDelete();
}


void SDVector::alloc(unsigned r, unsigned c)
{
	myDelete();
	m_row = r;
	m_col = c;
	m_data = new double [r * c];
}

void SDVector::myDelete() 
{
	if (m_data != 0) {
		delete [] m_data;
		m_row = 0;
		m_col = 0;
	}
}

double & SDVector::operator()(unsigned r, unsigned c)
{
	unsigned pos = r * m_col + c;
	return m_data[pos];
}
